//
//  MeTableViewController.m
//  WeChat
//
//  Created by wpapple on 16/6/15.
//  Copyright © 2016年 红红火火恍恍惚惚嘿嘿嘿. All rights reserved.
//

#import "MeTableViewController.h"
#import "AppDelegate.h"
#import "WPUserInfo.h"
#import "XMPPvCardTemp.h"
#import "WPXMPPTools.h"

@interface MeTableViewController()


@end

@implementation MeTableViewController


- (IBAction)logoutButton:(UIBarButtonItem *)sender {
    
//    AppDelegate * app = [UIApplication sharedApplication].delegate;
    [[WPXMPPTools sharedWPXMPPTools] goOffline];
    
    [WPUserInfo sharedWPUserInfo].loginStatus = NO;
    [[WPUserInfo sharedWPUserInfo] saveUserInfoToSandbox];

    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    WPUserInfo * wpUserInfo = [WPUserInfo sharedWPUserInfo];
    cell.textLabel.text = wpUserInfo.user;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@@eroco.local",wpUserInfo.user];
    
    XMPPvCardTemp *myVCard  = [WPXMPPTools sharedWPXMPPTools].vCardModule.myvCardTemp;
    
    if (myVCard.photo) {
        UIImage * photo = [UIImage imageWithData:myVCard.photo];
        
        [cell.imageView setImage:photo];
    }
    
    
    
    return cell;
}

@end
